
*==============================================================================*
*           Emission Rates and Exhaust Standards, Used Vehicles,               *
*                          Model Years 1982-2010                               *
*==============================================================================*
* this ends in model year 2010 for two reasons. first, that is the last year when
* new vehicle certification data distinguish LDV & LDT. second, that is the last
* year with colorado used vehicle inspection data.

*----------------------- panels A,C,E: exhaust standards ----------------------*
* ldtW is weighted by 1987 shares in CO smog check data; ldtW2 is weighted by 1993 shares
u "replicationFiles/dataSTATA/combined/combined_newcars.dta", clear
keep if model_year >= 1982 & model_year <= 2010


* the hc_nmhc series uses the conversion factor nmhc = 0.943 times thc, 
* noting that basically all vehicles have four-stroke engines 
* (see http://www.nytimes.com/2009/12/20/automobiles/20STROKE.html?_r=0 NYT 
* "A Two-Stroke Revival, Without the Blue Haze", Don Sherman, 2009).

* LDT are 100,000 miles, ldv are 50,000 miles. 125,000 miles has around 25% 
* higher emissions in these standards. don't multiply here, just note in the paper.

tw (connected standard_CO model_year if ldt == 0, msym(Sh)) ///
	(connected standard_CO model_year if ldt == 1, lpattern(dash)), ///
	graphr(color(white)) yscale(noline) legend(order(1 "Cars" 2 "Trucks")) ///
	xtit("Model Year") saving("results/figures/f2_standardsnewcars_19822010/standards_CO.gph", replace) ///
	xline(1983 1993 1996 2003, lcolor(black) lpattern(dash)) ///
	xlab(1982 1985 1990 1995 2000 2005 2010) ytit("Emission Rate") subtit("") ///
	ylab(0 5 10 15 20)
graph export "results/figures/f2_standardsnewcars_19822010/standards_CO.wmf", replace
graph export "$overleaf/figures/f2_standardsnewcars_19822010/standards_CO.eps", replace

tw (connected standard_HC model_year if ldt == 0, msym(Sh)) ///
	(connected standard_HC model_year if ldt == 1, lpattern(dash)), ///
	graphr(color(white)) yscale(noline) legend(order(1 "Cars" 2 "Trucks")) ///
	xtit("Model Year") saving("results/figures/f2_standardsnewcars_19822010/standards_HC.gph", replace) ///
	xline(1993 1996 2003 2006, lcolor(black)) ///
	xline(1983, lcolor(black) lpattern(dash)) ///
	xlab(1982 1985 1990 1995 2000 2005 2010) ///
	ytit("Emission Rate") subtit("")
graph export "results/figures/f2_standardsnewcars_19822010/standards_HC.wmf", replace
graph export "$overleaf/figures/f2_standardsnewcars_19822010/standards_HC.eps", replace

tw (connected standard_NOX model_year if ldt == 0, msym(Sh)) ///
	(connected standard_NOX model_year if ldt == 1, lpattern(dash)), ///
	graphr(color(white)) yscale(noline) legend(order(1 "Cars" 2 "Trucks")) ///
	xtit("Model Year") saving("results/figures/f2_standardsnewcars_19822010/standards_NOX.gph", replace) ///
	xline(1993 1996 2003 2006, lcolor(black)) ///
	xline(1987, lcolor(black) lpattern(dash)) ///
	xlab(1982 1985 1990 1995 2000 2005 2010) ytit("Emission Rate") subtit("")
graph export "results/figures/f2_standardsnewcars_19822010/standards_NOX.wmf", replace
graph export "$overleaf/figures/f2_standardsnewcars_19822010/standards_NOX.eps", replace


*------------------- panels B,C,D: new vehicle emission rates -----------------*
u "replicationFiles/dataSTATA/combined/combined_newcars.dta", clear
keep if model_year >= 1982 & model_year <= 2010

collapse (mean) emissions_new_*, by(model_year ldt)

tw  (connected emissions_new_CO model_year if ldt == 0, msym(Sh)) ///
	(connected emissions_new_CO model_year if ldt == 1, lpattern(dash)), ///
	graphr(color(white)) yscale(noline) legend(order(1 "Cars" 2 "Trucks")) ///
	xtit("Model Year") saving("results/figures/f2_standardsnewcars_19822010/newcars_CO.gph", replace) ///
	xline(1983 1993 1996 2003, lcolor(black) lpattern(dash)) ///
	xlab(1982 1985 1990 1995 2000 2005 2010) ytit("Emission Rate") subtit("")
graph export "results/figures/f2_standardsnewcars_19822010/newcars_CO.wmf", replace
graph export "$overleaf/figures/f2_standardsnewcars_19822010/newcars_CO.eps", replace
	
tw  (connected emissions_new_HC model_year if ldt == 0, msym(Sh)) ///
	(connected emissions_new_HC model_year if ldt == 1, lpattern(dash)), ///
	graphr(color(white)) yscale(noline) legend(order(1 "Cars" 2 "Trucks")) ///
	xtit("Model Year") saving("results/figures/f2_standardsnewcars_19822010/newcars_HC.gph", replace) ///
	xline(1993 1996 2003 2006, lcolor(black)) ///
	xline(1983, lcolor(black) lpattern(dash)) ///
	xlab(1982 1985 1990 1995 2000 2005 2010) ytit("Emission Rate") subtit("")
graph export "results/figures/f2_standardsnewcars_19822010/newcars_HC.wmf", replace
graph export "$overleaf/figures/f2_standardsnewcars_19822010/newcars_HC.eps", replace

tw  (connected emissions_new_NOX model_year if ldt == 0, msym(Sh)) ///
	(connected emissions_new_NOX model_year if ldt == 1, lpattern(dash)), ///
	graphr(color(white)) yscale(noline) legend(order(1 "Cars" 2 "Trucks")) ///
	xtit("Model Year") saving("results/figures/f2_standardsnewcars_19822010/newcars_NOX.gph", replace) ///
	xline(1993 1996 2003 2006, lcolor(black)) ///
	xline(1987, lcolor(black) lpattern(dash)) ///
	xlab(1982 1985 1990 1995 2000 2005 2010) ytit("Emission Rate") subtit("")
graph export "results/figures/f2_standardsnewcars_19822010/newcars_NOX.wmf", replace
graph export "$overleaf/figures/f2_standardsnewcars_19822010/newcars_NOX.eps", replace


